import {postBanner, postWishes} from '@/base/api/BannersApi';
import {deepAssign} from '@/base/util/Objects';
import {getAgentList} from '@/base/api/AgentApi';
import {Page} from '@/base/Page';
import {getCompanyList} from '@/base/api/CompanyApi';
import {Company} from '@/base/model/Company';
import {Agent} from '@/base/model/Agent';
import {ActivityAdd} from '@/base/model/ActivityAdd';
import {postActivity} from '@/base/api/ActivityApi';

export class FormBloc {
  form= new ActivityAdd();
  loading = false;
  fileList: Array<any> = [];
  fileList2: Array<any> = [];
  num: number = 0;
  sortList: any = [];
  // eslint-disable-next-line standard/object-curly-even-spacing
  awards=[{ name: '', quantity: 1, probability: 0, imgUrl: '', isValue: 0 }];
  awards2=[{ name: '', quantity: 1, probability: 0, imgUrl: '', isValue: 0 }];
  isDetail = false;
  isinfo = false;
  type: string | undefined;

  addActivity() {
    this.loading = true;
    console.log(this.form.activity1.Isfinite);
    // let activity1 = this.form.activity1.toArray();
    // let activity2 = this.form.activity2.toArray();
    return postActivity({
      activity1: JSON.stringify(this.form.activity1),
      activity2: JSON.stringify(this.form.activity2),
      awards1: JSON.stringify(this.awards),
      awards2: JSON.stringify(this.awards2)
    }).then((res) => {
      return res;
    }).finally(() => {
      this.loading = false;
    });
  }

  reset() {
    location.reload();
  }

}
